class Solution(object):
    def minDifference(self, nums):
        if len(nums) <= 3:
            return 0
        n = len(nums)
        nums.sort()
        min_val = float('inf')
        for i in range(3, -1, -1):
            min_val = min(nums[i + n - 4] - nums[i], min_val)
        return min_val
